function add() {
  let data = [].concat(Array.prototype.slice.call(arguments))
  function tmp() { // 使用闭包
    data = data.concat(Array.prototype.slice.call(arguments))
    return tmp;
  }
  tmp.valueOf = function () {
    return data.reduce(((source, item) => source + item), 0);
  }
  tmp.toString = function () {
    return data.reduce(((source, item) => source + item), 0);
  }
  return tmp
}
console.log(add(1)); // 1
console.log(add(1, 4)(2));  // 7
console.log(add(1)(2, 5)(3));// 11
console.log(add(1, 5, 6)(2, 5)(3)(4, 4));// 30
